package com.api.action.v1;

import com.admin.entity.Theme;
import com.admin.service.IThemeService;
import com.alibaba.fastjson.JSONObject;
import com.api.service.v1.TerminalApiService;
import com.bean.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
public class PaoMaDengAPI {


    @Autowired
    private TerminalApiService terminalApiService;


    @RequestMapping("/pmd/{mac}")
    public ResponseBean getPmd(@PathVariable("mac") String mac){
        if (mac==null || mac.trim().length()==0){
            return new ResponseBean(500,"mac地址不能为空",null);
        }

        Theme  theme = terminalApiService.findThemeByMac(mac);
        if (theme==null){
            return new ResponseBean(500,"非法mac",null);
        }

       try {
           String jsonString = theme.getThemeAuditAndroidAudited();
           JSONObject  pmdObject =JSONObject.parseObject(jsonString).getJSONObject("data").getJSONObject("CN").getJSONObject("desktop").getJSONObject("pmd");
           return new ResponseBean(200,"获取成功",pmdObject);
       }catch (Exception e){

       }

        return new ResponseBean(500,"获取跑马灯失败", null);


    }

}
